clear all; clc; close all;

load Hd;
N=1e6;
n = rand(1,N);
Fd = 44.2e6;
Td=1/Fd;
T = N*Td;
tmax =0.1;
y=filter(Hd.numerator,1,n);
figure(1);
f = 0:1/tmax:1/Td;
Sf=20*log10(abs(fft(y)));
Sf=Sf-max(Sf);
%plot(f/1e6, Sf);
%xlabel('f, MHz')
%grid on

 t = 0:Td:tmax;
N_PRN=1023; T_PRN=0.001;
PRN=sign(randn(1, N_PRN));
phase_h = mod(t/T_PRN,1)*N_PRN;
ind_h=fix(mod(t/T_PRN,1)*N_PRN)+1;
h = PRN(ind_h);

A=2;
f0=3e6/200;
phi=pi/4;

u=A*h.*cos(2*pi*f0*t+phi);
figure(2)
subplot(4,1,1)
plot(t,u)

subplot(4,1,2)
plot(t,h)

subplot(4,1,3)
plot(t,phase_h)

subplot(4,1,4)
plot(t,ind_h)

y=filter(Hd.numerator, 1, u);
f=0:1/tmax:1/Td;
Sf= 20*log10(abs(fft(y)));
Sf = Sf - max(Sf)+1;

figure(3)
plot(f/1e6, Sf);
xlim([0 Fd/2/1e6])
xlabel('f, MHz')
grid on
